﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <style type="text/CSS">
        .taskMenuItem {background-color: #C0C0C0; left: 20px; border: 2px solid #33CCFF; text-indent: 15px;}
        .taskMenuItem:hover {background-color: #3366FF}
    </style>
    <script type="text/javascript" src="/Scripts/szjt-allScripts.js"></script>
    <script type="text/javascript">
        function extKeyEvent() {
            if (window.event.keyCode == 27) {
                //alert("close dialog");
                _closeDialog();
            }
        }

        function setModuleMenu(menuId, menuName) {
            $("#mainLayout").layout("expand", "west");
            $("#mainLayout").layout("panel", "west").panel("setTitle", menuName);
            createModuleMenu(menuId);
        }
        
        function selectTask(taskGuid, taskName, taskUrl, taskIcon) {
            if (taskIcon.length == 0) taskIcon = undefined;
            _addMainTab(taskName, taskUrl, { useIFrame: taskUrl.indexOf("?") >= 0, fixedTab: true, iconCls: taskIcon });
        }

        var lastTabs = new Array();
        document.title = PrjConstant.SysInfo.ProjectName;
        $.fn.panel.defaults.loadingMessage = "正在加载数据……";
        $(document).ready(function () {
//            var userGuid = utility.page.getQueryString("user");
//            Session._userInfo.UserGuid = userGuid;
//            var memberInfo = dataService.getData(SysConstant.TaskGuid.OrgInfo, userGuid, Constant.SysDataType.OrgInfo.MemberInfo);
//            var memberXml = utility.xml.convertXmlStringToDoc(memberInfo);
//            Session._userInfo.UserName = memberXml.find("Name").text();

            //alert("index");
            document.onkeydown = extKeyEvent;
            $("#mainTabs").tabs({
                onSelect: function (title) {
                    lastTabs = $.grep(lastTabs, function (n, i) { return n != title; });
                    lastTabs.push(title);
                },
                onClose: function (title) {
                    lastTabs = $.grep(lastTabs, function (n, i) { return n != title; });
                    $("#mainTabs").tabs("select", lastTabs[lastTabs.length - 1]);
                }
            });
            $("#debugMode").text(dataService.localDebug ? "模拟模式" : "");
            $("#mainLayout").layout("collapse", "west");
            _addMainTab("待办事宜", "/Pages/PendingTasks.htm", { useIFrame: false, fixedTab: true, iconCls: "Msg.png" });
            //initMenuList();
            $("body").prepend("<div id='popupWin' style='z-index:1; height:100;'/>");
        });

        function _pageParameter(options, param) {
            return $.fn.szjt_pageParameter(options, param);
        }

        // useIFrame: default is true
        // fixedTab: default is false, if fixedTab is true, program will automatically remove all existing tabs before add the new tab.
        function _addMainTab(tabTitle, tabHref, options, parameters) {
            var opts = { useIFrame: true, fixedTab: false, refreshExisting: false };
            if (options) {
                opts = $.extend(opts, options);
            }
            //alert(tabHref);
            if (opts.fixedTab) {
                var tabs = $("#mainTabs").tabs("tabs");
                var length = tabs.length;
                for (var i = 0; i < length; i++) {
                    var onetab = tabs[0];
                    var title = onetab.panel('options').tab.text();
                    //var title = onetab.panel('options').title;  
                    $("#mainTabs").tabs("close", title);
                }
            }
            if ($("#mainTabs").tabs('exists', tabTitle)) {
                $("#mainTabs").tabs('select', tabTitle);

            } else {
                var closable = !(opts.fixedTab == true);
                //if (opts.useIFrame) {
                var pageContent = dataService.getPage(tabHref);
                var content = "<iframe name=\"" + tabTitle + "\" scrolling=\"auto\" height=\"100%\" width=\"100%\" frameborder=\"0\"  src=\"" + 
                    (pageContent ? tabHref : "/Pages/PageError.htm?href=" + tabHref) + "\"></iframe>";
                //var content = "<iframe scrolling=\"auto\" height=\"100%\" width=\"100%\" frameborder=\"0\">" + ss + "</iframe>";
                $("#mainTabs").tabs('add', {
                    title: tabTitle,
                    content: content,
                    closable: closable,
                    iconCls: opts.iconCls
                });
            }

            _pageParameter(parameters);
        }
        function _closeMainTab(tabTitle) {
            if (tabTitle == undefined) {
                tabTitle = _getCurrentTabTitle();
            }
            $("#mainTabs").tabs("close", tabTitle);
//            var pp = $("#mainTabs").tabs("getSelected");
        }
        function _getCurrentTabTitle() {
            var pp = $("#mainTabs").tabs("getSelected");
            return pp.panel('options').tab.text();
        }

        function _refreshPanel(panelTitle, operationType, operationTarget, isOperationSuccess) {
            var pp = $("#mainTabs").tabs("getTab", panelTitle);
            var opt = pp.panel('options');
            $("#mainTabs").tabs("update", { tab: pp, options: opt });
            _promptOperationResult(operationType, operationTarget, isOperationSuccess);
        }

        function _popupDialog(options, param) {
            var popupDefaults = { width: 500, height: 500, padding: 5,
                title: '', iconCls: 'icon-save', cache: false,
                shadow: true, inline: false,
                parentTitle: ''
                //onClose: _closeDialog, onSubmit: function () { }
            };
            var popupForces = { modal: true, collapsible: false, minimizable: false, maximizable: false };
            //$.fn.szjt_popupDialog(options, param);
            var opts = $.extend({}, popupDefaults, options, popupForces);
            var href = opts.href;
            var dialogParameter = opts['editParameter'];
            $.fn.szjt_pageParameter("editParameter", dialogParameter);
//            if (dialogParameter != undefined) {
//                if (dialogParameter.selectedList) {
//                    href += "?actionCode=" + dialogParameter.actionCode + "&&selectedList=" + dialogParameter.selectedList;
//                } else {
//                    href += "?actionCode=" + dialogParameter.actionCode;
//                }
//            }
            $("#popupWin").attr("parentTitle", opts.parentTitle);
            opts = $.extend({}, opts, { content: "<iframe scrolling=\"auto\" height=\"100%\" width=\"100%\" frameborder=\"0\" src=\"" + href + "\"></iframe>" });
            $("#popupWin").window(opts);

            var screenWidth, screenHeight;
            if ($.browser.msie) {
                screenWidth = document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
            }
            else {
                screenWidth = self.innerWidth;
            }
            if ($.browser.msie) {
                screenHeight = document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
            }
            else {
                screenHeight = self.innerHeight;
            }
            $("#popupWin").window("move", { left: (screenWidth - opts.width) / 2, top: (screenHeight - opts.height) / 2 });
            //$("#popupWin").window({ content: "<iframe scrolling=\"auto\" height=\"100%\" width=\"100%\" frameborder=\"0\" src=\"" + href + "\"></iframe>" });
        }

        function _closeDialog(refreshParent) {
            $("#popupWin").window("close");
            //alert("closed");
            if (refreshParent) {
                var parentTitle = _getCurrentTabTitle();
                if (parentTitle != undefined) {
                    if (window.frames[parentTitle].RefreshData != undefined) {
                        window.frames[parentTitle].RefreshData();
                    }
                }
//                var parentTitle = $("#popupWin").attr("parentTitle");
//                if (!parentTitle) {
//                    
//                }
            }
//            $("#popupWin").window({ content: "" });
        }

        function _promptOperationResult(operationType, operationTarget, isOperationSuccess) {
            utility.message.promptOperationResult(operationType, operationTarget, isOperationSuccess);
        }

    </script>
</head>
<body id="mainLayout" class="easyui-layout">
    <div region="north" border="false" href="Index_Top.htm" style="height: 60px; overflow: visible;background-color: #8fb9ed;">
    </div>
    <div region="west" split="true" title="模块功能" href="Index_Left.htm" style="width: 150px; padding: 0px; overflow: hidden;">
    </div>
    <div id="mainPanle" region="center" title="" style="overflow: hidden;padding:0px;">
            <div id="mainTabs" class="easyui-tabs" fit="true" border="true" plain="true">
            </div>
    </div>
    <div id="debugMode" style="width:70px; height:20px; position: absolute; right: 8px; top: 3px; z-index: 100;" />
	<div id="mm" class="easyui-menu" style="width:150px;display:none">
		<div id="mm-tabupdate">刷新</div>
		<div class="menu-sep"></div>
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div>

</body>
</html>
